#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    vector<int> findAnagrams(string s, string p)
    {
        if(s.size() < p.size())
            return {};
        vector<int> charCount(26, 0);
        vector<int> resultCount(26, 0);
        vector<int> result;
        for (char c : p)
        {
            resultCount[c - 'a']++;
        }
        for (int i = 0; i < p.size() - 1; i++)
        {
            charCount[s[i] - 'a']++;
        }
        for (int i = p.size() - 1; i < s.size(); i++)
        {
            charCount[s[i] - 'a']++;
            bool equal = true;
            for (int i = 0; i < 26; i++)
            {
                if (charCount[i] != resultCount[i])
                {
                    equal = false;
                    break;
                }
            }
            if (equal)
            {
                result.push_back(i - p.size() + 1);
            }
            charCount[s[i - p.size() + 1] - 'a']--;
        }
        return result;
    }
};
int main()
{
    cout << "Code438" << endl;
    Solution s;
    return 0;
}